package com.breaktian.assemble.http.retrofit;


import okhttp3.MediaType;
import okhttp3.RequestBody;
import retrofit2.Call;
import retrofit2.Callback;

/**
 * Created by breaktian on 2016/10/28.
 * http工具类
 */

public class HttpUtils {

    public static void getTest(Callback<String> callback){
        HttpDataProvider httpDataProvider = RetrofitProvider.get().create(HttpDataProvider.class);
        Call<String> call = httpDataProvider.getText();
        call.enqueue(callback);
    }

    public static void postJson(String json,Callback<String> callback){
        HttpDataProvider httpDataProvider = RetrofitProvider.get().create(HttpDataProvider.class);
        RequestBody body = RequestBody.create(MediaType.parse("application/json;charset=UTF-8"), json);
        Call<String> call = httpDataProvider.postJson(body);
        call.enqueue(callback);
    }


    /**
     * 根据手机号判断账号是否存在
     * */
//    public static void checkVerifyCode(String phone,String code,Callback<BaseResponseBean> callback){
//        CheckVerifyCodeRequestBean checkVerifyCodeRequestBean = new CheckVerifyCodeRequestBean();
//        checkVerifyCodeRequestBean.setMethod(Constants.HttpAction.ACCOUNT_API_CHECKVERIFYCODE);
//        checkVerifyCodeRequestBean.build();//添加公共参数
//        CheckVerifyCodeRequestBean.Params params = new CheckVerifyCodeRequestBean.Params();
//        params.setPhone(phone);
//        params.setVerifycode(code);
//        LogUtils.d("params json:"+new Gson().toJson(params));
//        checkVerifyCodeRequestBean.setParams(params);
//        checkVerifyCodeRequestBean.buildSign(params);
//        String json = new Gson().toJson(checkVerifyCodeRequestBean);
//        LogUtils.d("request json:"+json);
//
//        AccountService service = RetrofitProvider.get().create(AccountService.class);
//        Call<BaseResponseBean> call = service.checkVerifyCode(json);
//        call.enqueue(callback);
//
//    }

}
